export type CallBack = (num: number) => void


export function request(callBack: CallBack) {
  let callBack1: CallBack = (num) => {
  }
  callBack1(0)
}

export function request1(callBack: (num: number, msg: string) => boolean) {

}

export function selectParma(noSelectParma: number = 0, selectParma?: string) {

}


function nameParma(_parma?: {
  parma1: 0,
  parma2: ''
}) {

}

export function testLeaveParma(str: string, ...parma: number[]) {

}

export function testOnlyReadParma(str: readonly string[]) {
  // str[0] = '' 数组是可读的
}


// 这些代码编译会报错，提示命名冲突
// function add(x: number, y: number): number {
//   return 0
// }
//
// function add(x: string, y: string): string {
//   return ''
// }


/**
 * 高阶函数
 */
function higherOrder(): (bool: boolean) => number {
  let a = 1, b = 2
  return (bool: boolean) => a + b
}

export function testFunction() {
  selectParma()
  nameParma({ parma2: '', parma1: 0, })
  testLeaveParma('', 0, 1, 2)
  let result: number = higherOrder().call(true)
  console.log("testFunction higherOrder result", result)
}





